package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"log"
)

func main(){
	engine := gin.Default()

	//http://localhost:8080/hello?name=marin&class=软件工程
	engine.GET("/hello", func(context *gin.Context) {
		fmt.Println(context.FullPath())

		var student Student
		err := context.ShouldBindQuery(&student)
		if err != nil{
			log.Fatal(err.Error())
			return
		}

		fmt.Println(student.Name)
		fmt.Println(student.Class)

		context.Writer.Write([]byte("hello," + student.Name + student.Class))

	})

	engine.Run()
}

type Student struct{
	Name  string `form:"name"'`
	Class string `form:"class"`
}
